<?php

class subject_Form_FrmSubject extends Zend_Form
{

	public function init()
    {
        /* Form Elements & Other Definitions Here ... */
    	$this->setMethod('post');
    }
    function fromsuject($subjcetfrom = null){
    	$request=Zend_Controller_Front::getInstance()->getRequest();
		$db = new Application_Model_DbTable_DbGlobal();
		$sql = "Select fac_id,fac_name From tbl_faculty";
		$rows=$db->getGlobalDb($sql);
		//print_r($rows);exit();
		$options = array("" =>"- - - Select Type of Faculty - - -");	
		foreach($rows as $read) $options[$read['fac_id']]= $read['fac_name'];
		$fac = new Zend_Form_Element_Select('fac_id');
		$fac->setMultiOptions($options);
		$fac->setAttribs(array('fac_id'=>'fac_name','class'=>'form-control validate[required]'));
		
		$sql_dpt = " Select dpt_id,dpt_name From tbl_departments";
		$row_dpt = $db->getGlobalDb($sql_dpt);
		$opstion_dpt = array("" => " - - - Select Type of Department - - - ");
		foreach ($row_dpt as $read_dpt) $opstion_dpt[$read_dpt['dpt_id']] = $read_dpt['dpt_name'];
		$dpt_name = new Zend_Form_Element_Select("dpt_id");
		$dpt_name->setMultiOptions($opstion_dpt);
		$dpt_name->setAttribs(array('dpt_id'=>'dpt_name','class'=>'form-control validate[required]'));
		//print_r();exit();
		$sql_year = " Select year_id,year_name From tbl_year";
		$row_year = $db->getGlobalDb($sql_year);
		$opstion_year = array("" => " - - - Select Type of Year - - - ");
		foreach ($row_year as $read_year) $opstion_year[$read_year['year_id']] = $read_year['year_name'];
		$year_name = new Zend_Form_Element_Select("year_id");
		$year_name->setMultiOptions($opstion_year);
		$year_name->setAttribs(array('year_id'=>'year_name','class'=>'form-control validate[required]'));
		//print_r();exit();
		$sql_semester = " Select semester_id,semester_name From tbl_semester";
		$row_semester = $db->getGlobalDb($sql_semester);
		$opstion_semester = array("" => " - - - Select Type of Semester - - - ");
		foreach ($row_semester as $read_semester) $opstion_semester[$read_semester['semester_id']] = $read_semester['semester_name'];
		$semester_name = new Zend_Form_Element_Select("semester_id");
		$semester_name->setMultiOptions($opstion_semester);
		$semester_name->setAttribs(array('semester_id'=>'semester_name','class'=>'form-control validate[required]'));
		//print_r();exit();
    	$subject = new Zend_Form_Element_Text("subject_name");    	   	
    		$subject->setAttribs(array("class"=>"form-control validate[required]"));
    	$description = new Zend_Form_Element_Textarea("description");
    		$description->setAttribs(array("class"=>"form-textarea "));	
    	$ordering = new Zend_Form_Element_Text("ordering");
    		$ordering->setAttribs(array("class"=>"form-control validate[required]"));
    		$id = new Zend_Form_Element_Hidden("subject_id");
    	$this->addElements( array($fac,$dpt_name,$subject,$ordering,$description,$id,$semester_name,$year_name));    	
    	if($subjcetfrom !=""){    	
    		$id->setValue($subjcetfrom['subject_id']);
    		$fac->setValue($subjcetfrom['fac_id']);
    		$semester_name->setValue($subjcetfrom['semester_id']);
    		$year_name->setValue($subjcetfrom['year_id']);
    		$dpt_name->setValue($subjcetfrom['dpt_id']);
    		$subject->setValue($subjcetfrom['subject_name']);
    		$description->setValue($subjcetfrom['description']);
    		$ordering->setValue($subjcetfrom['ordering']);
    	}
    	return $this;
    }
}
    	